package cn.qicaiwang.open.app.controller;

import cn.qicaiwang.open.app.entity.AdmissionCard;
import cn.qicaiwang.open.app.server.PdfCustomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;

@RestController
@RequestMapping("qcwapp/pdf")
public class PdfController {
    @Autowired
    private PdfCustomService pdfCustomService;

    /**
     * 导出PDF
     * @param admissionCard
     * @param response
     */
    @PostMapping("/admissioncard")
    public void generatorAdmissionCard(@RequestBody AdmissionCard admissionCard, HttpServletResponse response){
        try {
            pdfCustomService.generatorAdmissionCard(admissionCard, response);
        } catch (UnsupportedEncodingException | FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
